---
title: "Netlify Deployer"
description: "Documentation for the NetlifyDeployer class, which deploys Kastrax applications to Netlify Functions."
---

# NetlifyDeployer ✅

The NetlifyDeployer deploys Kastrax applications to Netlify Functions, handling site creation, configuration, and deployment processes. It extends the abstract Deployer class to provide Netlify-specific deployment functionality.

## Usage Example ✅

```typescript
import { Kastrax } from '@kastrax/core';
import { NetlifyDeployer } from '@kastrax/deployer-netlify';

const kastrax = new Kastrax({
  deployer: new NetlifyDeployer({
    scope: 'your-team-slug',
    projectName: 'your-project-name',
    token: 'your-netlify-token'
  }),
  // ... other Kastrax configuration options
});
```

## Parameters ✅

### Constructor Parameters

<PropertiesTable
  content={[
    {
      name: "scope",
      type: "string",
      description: "Your Netlify team slug or ID.",
      isOptional: false,
    },
    {
      name: "projectName",
      type: "string",
      description: "Name of your Netlify site (will be created if it doesn't exist).",
      isOptional: false,
    },
    {
      name: "token",
      type: "string",
      description: "Your Netlify authentication token.",
      isOptional: false,
    },
  ]}
/>


### Environment Variables

The NetlifyDeployer handles environment variables from multiple sources:

1. **Environment Files**: Variables from `.env.production` and `.env` files.
2. **Configuration**: Variables passed through the Kastrax configuration.
3. **Netlify Dashboard**: Variables can also be managed through Netlify's web interface.


## Build Kastrax Project ✅

To build your Kastrax project for Netlify deployment:

```bash
npx kastrax build
```

The build process generates the following output structure in the `.kastrax/output` directory:

```
.kastrax/output/
├── netlify/
│   └── functions/
│       └── api/
│           └── index.mjs    # Application entry point
└── netlify.toml             # Netlify configuration
```

### Netlify Configuration

The NetlifyDeployer automatically generates a `netlify.toml` configuration file in `.kastrax/output` with the following settings:

```toml
[functions]
node_bundler = "esbuild"            
directory = "netlify/functions"

[[redirects]]
force = true
from = "/*"
status = 200
to = "/.netlify/functions/api/:splat"
```

## Deployment Options ✅

After building, you can deploy your Kastrax application `.kastrax/output` to Netlify using any of these methods:

1. **Netlify CLI**: Deploy directly using Netlify's official CLI tool
   - Install the CLI: `npm install -g netlify-cli`
   - Navigate to the output directory: `cd .kastrax/output`
   - Deploy with functions directory specified: `netlify deploy --dir . --functions ./netlify/functions`
   - For production deployment add `--prod` flag: `netlify deploy --prod --dir . --functions ./netlify/functions`

2. **Netlify Dashboard**: Connect your Git repository or drag-and-drop the build output through the Netlify dashboard

3. **Netlify Dev**: Run your Kastrax application locally with Netlify's development environment

> You can also run `netlify dev` in your output directory `.kastrax/output` to test your Kastrax application locally.

## Platform Documentation ✅

- [Netlify](https://docs.netlify.com/)